/*
-------------------------------------------------------------------
BIE is Copyright 2001-2003 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
*/
/*
 * SoapServiceEndpoint.java
 * 
 * This is a simple class that contains:
 * The endpoint address (url);
 * The name space that the service use to identify itself to the server 
 * (targetNameSpace); and
 * The method to invoke in that service (method).
 * Heaps of getter and setter methods. Maybe not very smart???
 * Tried to abstain from using Axis APIs, in case, if we dun want to import 
 * these packages.
 *
 * Created on January 13, 2003, 9:01 AM
 */

package com.webdeninteractive.sbie.soap;

import com.webdeninteractive.sbie.ServiceEndpoint;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.log4j.Logger;

/** ServiceEndpoint for use with the SoapProtocolHander.
 *
 * @author  mlee
 */
public class SoapServiceEndpoint implements ServiceEndpoint {
    
    private URL url = null;
    private String targetNameSpace = "";
    private String methodName = "noMethod";
    private String username = null;
    private String password = null;

    private Logger logger = Logger.getLogger( "com.webdeninteractive.sbie.soap.SoapServiceEndpoint" );

    public String toString() {
        return "(username=" + username + ";password=" + password +
            ";url=" + url.toExternalForm() + ";method=" + methodName +
            ";ns=" + targetNameSpace + ")";
    }

    /** Attempting to assign an invalid URL to this method will result
     *  in the url remaining null. */
    public void setTarget( String uri ) {
        try { 
            url = new URL(uri);
        } catch (MalformedURLException e) {
            logger.warn("Failed to construct endpoint url: " + e);
            logger.debug(e);
            url = null; // bad, but can't throw exception
        }
    }

    public URL getTargetEndpointAddress() {
        return this.url;
    }

    public void setTargetNameSpace(String target){
        targetNameSpace = target;
    }
    
    public String getTargetNameSpace(){
        return targetNameSpace;
    }
    
    public void setMethod(String method){
        methodName = method;
    }
    
    public String getMethod(){
        return methodName;
    }

    public void setUser( String username ) {
        this.username = username;
    }

    public String getUser() {
        return this.username;
    }

    public void setPassword( String password ) {
        this.password = password;
    }

    public String getPassword() {
        return this.password;
    }

}
